fix(eda): inherit KiCad reference prefix from ancestor categories - #1547
wangzhengzhuo05 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1547 +/- ##
=========================================
Coverage 62.40% 62.40%
- Complexity 9879 9886 +7
=========================================
Files 736 736
Lines 31782 31795 +13
=========================================
+ Hits 19832 19842 +10
- Misses 11950 11953 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I think it would be good that if we do all the recursion, that the result for each category is cached somehow (at least inside the request itself), so that when a part list for categories is created, so the work does not increase linearly with the amount of parts, but something much less. |
|
Thanks @jbtronics — closing this. You are right about the caching point: doing the full ancestor walk per category means the work grows with the number of parts, and caching the per-category result (at minimum for the lifetime of the request) is the right shape. I am not able to follow up on that in the near term, so rather than leave this sitting in your review queue with an open question attached, I am closing it. For the record, what the branch did: The branch |
What
A part in a nested EDA category did not inherit the
Reference Prefixof an ancestor category.KiCadHelper::getKiCADPart()only consulted the part's own EDA info and then its immediatecategory, so in the tree below a part placed from
D-subgot refdesU?instead ofJ?:Why
src/Services/EDA/KiCadHelper.php:214resolved the prefix aspart->edaInfo->prefix ?? part->category->edaInfo->prefix ?? 'U'— the category lookup wassingle-level, so any deeper category lost the inherited prefix. Per #1535 the prefix should be
inherited from the next highest category that defines one.
How
Added a private
getReferencePrefix(Part $part)helper and used it for thereferencefield:that defines a non-empty prefix wins;
nulland''count as "not set", so a blank prefix field inherits (the reported case);'U'fallback is unchanged when nothing in the chain defines a prefix;in
AbstractStructuralDBElement.Only the
referencefield is affected — the other EDA fields and the visibility checks areuntouched.
Tests
Four new tests in
tests/Services/EDA/KiCadHelperTest.php:testReferencePrefixIsInheritedFromAncestorCategory— part blank,D-subblank, parentConnectors=J->JtestNearestCategoryWithPrefixWins—D-sub=X, parentConnectors=J->XtestPartReferencePrefixOverridesCategory— part =C, parentConnectors=J->CtestReferencePrefixFallsBackToUWhenNothingIsSet— nothing set ->UMutation check
Restoring line 214 to the previous single-level lookup (leaving the new tests in place) makes the
regression test fail with exactly the reported symptom, then reverting the mutation goes green:
Fixes #1535